<script>
	export default {
		// 全局变量
		globalData: {
			district: '', //地区
			pcd: '',
			system: ''
		},
		onLaunch: function() {
			this.checkForUpdates()
			const res = uni.getSystemInfoSync()
			const system = res.platform
			getApp().globalData.system = system
			let statusBarHeight = res.statusBarHeight
			let titleHeight = 0
			if (system === 'android') {
				titleHeight = (48 + statusBarHeight)
			} else if (system === 'ios') {
				titleHeight = (44 + statusBarHeight)
			}
			Vue.prototype.naviBarHeight = (titleHeight - statusBarHeight) + 'px'
			Vue.prototype.IMG = 'https://ossweb-img.qq.com/images/lol/web201310/skin/big1000'
		},
		methods: {
			checkForUpdates() {
				this.$u.api.checkForUpdates({
					type: getApp().globalData.system == 'android' ? 1 : 2
				}).then(res => {
					plus.runtime.getProperty(plus.runtime.appid, (appRes) => {
						const {
							appVersion,
							versionContent,
							url
						} = res
						
						if (appVersion != appRes.version) {
							uni.showModal({
								title: '更新提醒',
								content: versionContent,
								success(type) {
									if (type.confirm) {
										plus.runtime.openURL(url)
									}
								}
							})
						}
					})

				})
			},
		}
	}
</script>


<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */

	/* #ifndef APP-NVUE */
	@import "uview-ui/index.scss";
	@import 'static/css/reset.scss';
	/* #endif */

	/*每个页面公共css */
</style>
